qui(
    function (require, exports, module) {
        Director.Grid = function (options) {
            this.dao = Director.Dao;
            this.config = Director.Config;
            this.task = Director.Task;
            this.options = options || {};
        };
        Com.inherits(Director.Grid, Ancestor.Grid).extend({
            /* program director end */
            initLibraryGrid: function (options) {
                var self = this;
                var taskArr = [];
                taskArr.push(self.task.getLogType(self.dao.cfgName.LogType));
                $.each(taskArr, function (index, element) {
                    EpgWeb.ajaxQueue.push(element.regName, element.options);
                })
                EpgWeb.ajaxQueue.afterLoadComplete(function () {
                    var params = self.getParam();
                    var gridConfig = self.getGridConfig(self.config.TABLE_LIST);
                    //params.rowNum=10;
                    options = $.extend(true, {
                        mtype: 'post',
                        postData: $.extend(true, {}, params)
                    }, gridConfig, options);
                    self.$grid.jqGrid(options);
                    self.echoQuery();
                })
                EpgWeb.ajaxQueue.startLoad();
            },
            runLibrary: function () {
                var self = this;
                self.$grid = self.options.$grid;
                self.bindBasicEvent();
                Director.Util.bindDate("startDate", "endDate");
                self.initLibraryGrid({})
            },

            echoQuery: function () {
                var self = this;
                self.query();
            },

            query: function () {
                var self = this;
                var $grid = self.$grid;
                var params = self.getParam();
                $grid.jqGrid('setGridParam', {
                    page: 1,
                    datatype: "json",
                    postData: params
                }).trigger('reloadGrid');
            },

            reload: function () {
                var self = this;
                var $grid = self.$grid;
                $grid.trigger('reloadGrid');
            },

            getParam: function () {
                var self = this;
                var $container = self.options.$container;

                var params = {};
                var $form = $container.find('form[name="basicFrm"]');

                var $elements = $.makeArray($form.prop('elements')).filter(function () {
                    return true; //this.name;
                });

                var name;
                var key;
                $.each($elements, function () {
                    name = this.name;
                    if (name) {
                        if (this.type == 'radio') {
                            params[name] = $('input[name="' + name + '"]:checked').val() || '';
                        } else
                            params[name] = $.trim($(this).val()) || '';
                    }
                });

                return params;
            },

            bindBasicEvent: function () {
                var self = this;
                var $container = self.options.$container;
                var $form = $container.find('form[name="basicFrm"]');
                $form.find('.query-btn').on('click', function () {
                    self.query();
                    return false;
                });
                $form.find('button[type="reset"]').click(function () {
                    self.resetQueryForm();
                });
            }
            /* program director end */

        })
    }
);